<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Return information about a file</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.finfo-close.html">finfo_close</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.finfo-open.html">finfo_open</a></div>
 <div class="up"><a href="ref.fileinfo.html">Fileinfo 函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="function.finfo-file" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">finfo_file</h1>
  <h1 class="refname">finfo::file</h1>
  <p class="verinfo">(PHP &gt;= 5.3.0, PECL fileinfo &gt;= 0.1.0)</p><p class="refpurpose"><span class="refname">finfo_file</span> -- <span class="refname">finfo::file</span> &mdash; <span class="dc-title">Return information about a file</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.finfo-file-description">
  <h3 class="title">说明</h3>
  <p class="para">过程化风格</p>
  <div class="methodsynopsis dc-description">
   <span class="type">string</span> <span class="methodname"><strong>finfo_file</strong></span>
    ( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$finfo</code></span>
   , <span class="methodparam"><span class="type">string</span> <code class="parameter">$file_name</code><span class="initializer"> = <strong><code>NULL</code></strong></span></span>
   [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$options</code><span class="initializer"> = FILEINFO_NONE</span></span>
   [, <span class="methodparam"><span class="type">resource</span> <code class="parameter">$context</code><span class="initializer"> = <strong><code>NULL</code></strong></span></span>
  ]] )</div>

  <p class="para rdfs-comment">面向对象风格</p>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">string</span> <span class="methodname"><strong>finfo::file</strong></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$file_name</code><span class="initializer"> = <strong><code>NULL</code></strong></span></span>
   [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$options</code><span class="initializer"> = FILEINFO_NONE</span></span>
   [, <span class="methodparam"><span class="type">resource</span> <code class="parameter">$context</code><span class="initializer"> = <strong><code>NULL</code></strong></span></span>
  ]] )</div>


  <p class="para rdfs-comment">
   This function is used to get information about a file.
  </p>

 </div>

 <div class="refsect1 parameters" id="refsect1-function.finfo-file-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<em><code class="parameter">finfo</code></em></dt>

     <dd>

      <p class="para">
       Fileinfo resource returned by <span class="function"><a href="function.finfo-open.html" class="function">finfo_open()</a></span>.
      </p>
     </dd>

    
    
     <dt>
<em><code class="parameter">file_name</code></em></dt>

     <dd>

      <p class="para">
       Name of a file to be checked.
      </p>
     </dd>

    
    
     <dt>
<em><code class="parameter">options</code></em></dt>

     <dd>

      <p class="para">
       One or disjunction of more <a href="fileinfo.constants.html" class="link">Fileinfo
       constants</a>.
      </p>
     </dd>

    
    
     <dt>
<em><code class="parameter">context</code></em></dt>

     <dd>

      <p class="para">
       For a description of <em>contexts</em>, refer to <a href="ref.stream.html" class="xref">Stream 函数</a>.
      </p>
     </dd>

    
   </dl>

  </p>
 </div>

 <div class="refsect1 returnvalues" id="refsect1-function.finfo-file-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   Returns a textual description of the contents of the
   <em><code class="parameter">filename</code></em> argument, or <strong><code>FALSE</code></strong> if an error occurred.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.finfo-file-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-2279">
    <p><strong>Example #1 A <span class="function"><strong>finfo_file()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$finfo&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">finfo_open</span><span style="color: #007700">(</span><span style="color: #0000BB">FILEINFO_MIME_TYPE</span><span style="color: #007700">);&nbsp;</span><span style="color: #FF8000">//&nbsp;return&nbsp;mime&nbsp;type&nbsp;ala&nbsp;mimetype&nbsp;extension<br /></span><span style="color: #007700">foreach&nbsp;(</span><span style="color: #0000BB">glob</span><span style="color: #007700">(</span><span style="color: #DD0000">"*"</span><span style="color: #007700">)&nbsp;as&nbsp;</span><span style="color: #0000BB">$filename</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #0000BB">finfo_file</span><span style="color: #007700">(</span><span style="color: #0000BB">$finfo</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$filename</span><span style="color: #007700">)&nbsp;.&nbsp;</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">finfo_close</span><span style="color: #007700">(</span><span style="color: #0000BB">$finfo</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>以上例程的输出类似于：</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
text/html
image/gif
application/vnd.ms-excel
</pre></div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.finfo-file-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="function.finfo-buffer.html" class="function" rel="rdfs-seeAlso">finfo_buffer()</a> - Return information about a string buffer</span></li>
   </ul>
  </p>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.finfo-close.html">finfo_close</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.finfo-open.html">finfo_open</a></div>
 <div class="up"><a href="ref.fileinfo.html">Fileinfo 函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
